package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	r:= gin.Default()
	//限制表单上传大小
	r.MaxMultipartMemory =8 << 20
	r.POST("/upload", func(c *gin.Context) {
		form ,err := c.MultipartForm()
		if err !=nil {
			c.String(http.StatusBadRequest,fmt.Sprintf("get err %s", err.Error()))
		}
		//获取所有图片
		files := form.File["files"]
		//便利
		for _,file :=range files{
			//逐个存
		if err := c.SaveUploadedFile(file,file.Filename); err !=nil{
			c.String(http.StatusBadRequest,fmt.Sprintf("upload err %s", err.Error()))
			return
		}
		}
		c.String(http.StatusOK,fmt.Sprintf("upload ok %d files", len(files)))
	})
	 r.Run(":8200")
}
